package com.my.mvvmrapid.ui.main.viewpager;

import com.my.mvvmrapid.ui.main.fragment.homeali.HomeALiFragment;
import com.my.mvvmrapid.ui.main.fragment.homelist.HomeListFragment;
import com.my.mvvmrapid.ui.main.fragment.homepersonal.HomePersonalFragment;
import com.my.mvvmrapid.ui.main.fragment.homeshop.HomeShopFragment;
import com.my.mvvmrapid.ui.main.fragment.homewan.HomeWanFragment;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.Lifecycle;
import androidx.viewpager2.adapter.FragmentStateAdapter;

public class ViewPagerFragmentStateAdapter extends FragmentStateAdapter {

    public ViewPagerFragmentStateAdapter(@NonNull FragmentManager fragmentManager, @NonNull Lifecycle lifecycle) {
        super(fragmentManager, lifecycle);
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        switch (position) {
            case 0:
                return HomeWanFragment.newInstance();
            case 1:
                return HomeALiFragment.newInstance();
            case 2:
                return HomeShopFragment.newInstance();
            case 3:
                return HomeListFragment.newInstance();
            case 4:
            default:
                return HomePersonalFragment.newInstance();
        }
    }

    @Override
    public int getItemCount() {
        return 5;
    }

}
